#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 998244353
#define N 1000010
#define int long long
#define db double
#define szi sizeof(int)
#define il inline
int T,n,m,k,l,vm,x,y,d[N],v[N],a[N],p[N],mn,mx;
struct itv{
    int l,r;
    il bool operator <(const itv &a){return (l!=a.l)?(l>a.l):(r<a.r);}
}t[N],s[N];
il void ins(int l,int r){
    if(!l){if(p[r]) t[++k]={l,r}; return ;}
    if(p[r]-p[l-1]>0) t[++k]={l,r}; return ;
}
il bool chk(int s,int i){
    if(v[i]*v[i]+2*a[i]*s<0) return false;
    db v2=sqrt(2.0*a[i]*s+(db)v[i]*v[i]);
    return (v2>(db)vm);
}
il void solve(){
    scanf("%lld%lld%lld%lld",&n,&m,&l,&vm);
    memset(p,0,szi*(l+1)),k=0;
    for(int i=1;i<=n;++i)
        scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
    for(int i=1;i<=m;++i) scanf("%lld",&x),++p[x];
    for(int i=1;i<=l;++i) p[i]+=p[i-1];
    for(int i=1,ll,rr,mm;i<=n;++i){
        if(!a[i]){if(v[i]>vm) ins(d[i],l);}
        if(a[i]>0){
            if(v[i]>vm){ins(d[i],l);;continue;}
            ll=d[i],rr=l;
            while(ll<=rr){
                mm=ll+rr>>1; if(chk(mm-d[i],i)) rr=mm-1; else ll=mm+1;
            }
            if(ll<=l) ins(ll,l);
        }
        if(a[i]<0){
            if(v[i]<=vm) continue;
            ll=d[i],rr=l;
            while(ll<=rr){
                mm=ll+rr>>1; if(chk(mm-d[i],i)) ll=mm+1; else rr=mm-1;
            }
            if(rr>=d[i]) ins(d[i],rr);
        }
    }
    printf("%lld ",k),sort(t+1,t+k+1),n=0,mn=l+1;
    for(int i=1;i<=k;++i)
        if(mn>t[i].r) mn=t[i].r,s[++n]=t[i];
    for(int i=l;i>=1;--i) p[i]=(p[i]>p[i-1])?i:-1;
    p[0]=(p[0])?0:-1;
    for(int i=1;i<=l;++i) if(p[i]==-1) p[i]=p[i-1];
    reverse(s+1,s+n+1),mx=-1;
    for(int i=1;i<=n;++i) if(mx<s[i].l) mx=p[s[i].r],--m;
    printf("%lld\n",m);
    return ;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T); while(T--) solve();
    return 0;
}
